<!DOCTYPE html>
<html lang=en>
<head>
  <meta charset="utf-8">
  
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-transform" />
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="format-detection" content="telephone=no,email=no,adress=no">
  <!-- Color theme for statusbar -->
  <meta name="theme-color" content="#000000" />
  <!-- 强制页面在当前窗口以独立页面显示,防止别人在框架里调用页面 -->
  <meta http-equiv="window-target" content="_top" />
  
  
  <title>面试准备 | 鲨鱼之家</title>
  <meta name="description" content="一、机器学习必知算法  1. Linear Regression 线性回归 2. Logistic Regression 逻辑回归 3. Decision Trees 决策树 4. Random Forests 随机森林 5. SVM支持向量机 6. KNN K-近邻 7. K-means K均值 8. Naive Bayes 朴素贝叶斯 9. 降维算法   二、深度学习基础  CS231n笔">
<meta property="og:type" content="article">
<meta property="og:title" content="面试准备">
<meta property="og:url" content="http://tina-yao.gitee.io/bigbig-shark/2022/10/03/%E9%9D%A2%E8%AF%95%E5%87%86%E5%A4%87/index.html">
<meta property="og:site_name" content="大鲨鱼">
<meta property="og:description" content="一、机器学习必知算法  1. Linear Regression 线性回归 2. Logistic Regression 逻辑回归 3. Decision Trees 决策树 4. Random Forests 随机森林 5. SVM支持向量机 6. KNN K-近邻 7. K-means K均值 8. Naive Bayes 朴素贝叶斯 9. 降维算法   二、深度学习基础  CS231n笔">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="https://gitee.com/tina-yao/bigbig-shark/raw/master/imgs/iPadEntrance/2.png">
<meta property="og:image" content="https://gitee.com/tina-yao/bigbig-shark/raw/master/imgs/iPadEntrance/1.png">
<meta property="og:image" content="https://gitee.com/tina-yao/bigbig-shark/raw/master/imgs/iPadEntrance/3.png">
<meta property="og:image" content="https://gitee.com/tina-yao/bigbig-shark/raw/master/imgs/iPadEntrance/4.png">
<meta property="og:image" content="https://gitee.com/tina-yao/bigbig-shark/raw/master/imgs/iPadEntrance/5.png">
<meta property="og:image" content="https://gitee.com/tina-yao/bigbig-shark/raw/master/imgs/iPadEntrance/6.png">
<meta property="article:published_time" content="2022-10-03T02:57:32.000Z">
<meta property="article:modified_time" content="2022-10-21T02:48:32.299Z">
<meta property="article:author" content="BigbigShark">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gitee.com/tina-yao/bigbig-shark/raw/master/imgs/iPadEntrance/2.png">
  <!-- Canonical links -->
  <link rel="canonical" href="http://tina-yao.gitee.io/bigbig-shark/2022/10/03/%E9%9D%A2%E8%AF%95%E5%87%86%E5%A4%87/index.html">
  
    <link rel="alternate" href="/atom.xml" title="大鲨鱼" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png" type="image/x-icon">
  
  
<link rel="stylesheet" href="/bigbig-shark/css/style.css">

  
  
  
  
<meta name="generator" content="Hexo 5.4.0"></head>


<body class="main-center theme-purple# 主题颜色 theme-black theme-blue theme-green theme-purple" itemscope itemtype="http://schema.org/WebPage">
  <header class="header" itemscope itemtype="http://schema.org/WPHeader">
  <div class="slimContent">
    <div class="navbar-header">
      
      
      <div class="profile-block text-center">
        <a id="avatar" href="https://tina-yao.gitee.io/bigbig-shark/" target="_blank">
          <img class="img-circle img-rotate" src="/bigbig-shark/images/avatar.jpg" width="200" height="200">
        </a>
        <h2 id="name" class="hidden-xs hidden-sm">大鲨鱼</h2>
        <h3 id="title" class="hidden-xs hidden-sm hidden-md">CV&amp;Robots</h3>
        <small id="location" class="text-muted hidden-xs hidden-sm"><i class="icon icon-map-marker"></i> Wuhan, China</small>
      </div>
      
      <div class="search" id="search-form-wrap">

    <form class="search-form sidebar-form">
        <div class="input-group">
            <input type="text" class="search-form-input form-control" placeholder="Search" />
            <span class="input-group-btn">
                <button type="submit" class="search-form-submit btn btn-flat" onclick="return false;"><i class="icon icon-search"></i></button>
            </span>
        </div>
    </form>
    <div class="ins-search">
  <div class="ins-search-mask"></div>
  <div class="ins-search-container">
    <div class="ins-input-wrapper">
      <input type="text" class="ins-search-input" placeholder="Type something..." x-webkit-speech />
      <button type="button" class="close ins-close ins-selectable" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
    </div>
    <div class="ins-section-wrapper">
      <div class="ins-section-container"></div>
    </div>
  </div>
</div>


</div>
      <button class="navbar-toggle collapsed" type="button" data-toggle="collapse" data-target="#main-navbar" aria-controls="main-navbar" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
    </div>
    <nav id="main-navbar" class="collapse navbar-collapse" itemscope itemtype="http://schema.org/SiteNavigationElement" role="navigation">
      <ul class="nav navbar-nav main-nav menu-highlight">
        
        
        <li class="menu-item menu-item-home">
          <a href="/bigbig-shark/.">
            
            <i class="icon icon-home-fill"></i>
            
            <span class="menu-title">Home</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-archives">
          <a href="/bigbig-shark/archives">
            
            <i class="icon icon-archives-fill"></i>
            
            <span class="menu-title">Archives</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-categories">
          <a href="/bigbig-shark/categories">
            
            <i class="icon icon-folder"></i>
            
            <span class="menu-title">Categories</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-tags">
          <a href="/bigbig-shark/tags">
            
            <i class="icon icon-tags"></i>
            
            <span class="menu-title">Tags</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-links">
          <a href="/bigbig-shark/links">
            
            <i class="icon icon-friendship"></i>
            
            <span class="menu-title">Links</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-about">
          <a href="/bigbig-shark/about">
            
            <i class="icon icon-cup-fill"></i>
            
            <span class="menu-title">About</span>
          </a>
        </li>
        
      </ul>
      
	
    <ul class="social-links">
    	
        <li><a href="https://gitee.com/tina-yao" target="_blank" title="Gitee" data-toggle=tooltip data-placement=top><i class="icon icon-gitee"></i></a></li>
        
    </ul>

    </nav>
  </div>
</header>

  
    <aside class="sidebar" itemscope itemtype="http://schema.org/WPSideBar">
  <div class="slimContent">
    
      <div class="widget">
    <h3 class="widget-title">Board</h3>
    <div class="widget-body">
        <div id="board">
            <div class="content">
                <p>欢迎交流与分享经验!</p>
            </div>
        </div>
    </div>
</div>

    
      
  <div class="widget">
    <h3 class="widget-title">Categories</h3>
    <div class="widget-body">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/bigbig-shark/categories/AI/">AI</a><span class="category-list-count">1</span><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/bigbig-shark/categories/AI/ML/">ML</a><span class="category-list-count">1</span></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/bigbig-shark/categories/Concepts/">Concepts</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/bigbig-shark/categories/Robots/">Robots</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/bigbig-shark/categories/%E5%8D%8A%E6%97%A5%E9%97%B2/">半日闲</a><span class="category-list-count">5</span></li><li class="category-list-item"><a class="category-list-link" href="/bigbig-shark/categories/%E6%95%B0%E5%AD%A6%E5%BB%BA%E6%A8%A1/">数学建模</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/bigbig-shark/categories/%E6%95%B0%E6%8D%AE%E5%88%86%E6%9E%90/">数据分析</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/bigbig-shark/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E8%A7%86%E8%A7%89/">计算机视觉</a><span class="category-list-count">30</span></li></ul>
    </div>
  </div>


    
      
  <div class="widget">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget-body tagcloud">
      <a href="/bigbig-shark/tags/CNN-backbones/" style="font-size: 13.67px;">CNN_backbones</a> <a href="/bigbig-shark/tags/OpenCV/" style="font-size: 13px;">OpenCV</a> <a href="/bigbig-shark/tags/Python/" style="font-size: 13px;">Python</a> <a href="/bigbig-shark/tags/ROS/" style="font-size: 13px;">ROS</a> <a href="/bigbig-shark/tags/%E4%BB%A3%E7%A0%81/" style="font-size: 13px;">代码</a> <a href="/bigbig-shark/tags/%E5%85%83%E5%AE%87%E5%AE%99/" style="font-size: 13px;">元宇宙</a> <a href="/bigbig-shark/tags/%E5%85%B4%E8%B6%A3/" style="font-size: 13px;">兴趣</a> <a href="/bigbig-shark/tags/%E5%9C%BA%E6%99%AF%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB/" style="font-size: 13px;">场景文字识别</a> <a href="/bigbig-shark/tags/%E6%91%98%E6%8A%84/" style="font-size: 13.33px;">摘抄</a> <a href="/bigbig-shark/tags/%E6%95%B0%E6%8D%AE%E9%9B%86/" style="font-size: 13px;">数据集</a> <a href="/bigbig-shark/tags/%E7%9B%AE%E6%A0%87%E6%A3%80%E6%B5%8B/" style="font-size: 14px;">目标检测</a> <a href="/bigbig-shark/tags/%E7%BE%8E%E8%B5%9B/" style="font-size: 13px;">美赛</a> <a href="/bigbig-shark/tags/%E8%81%9A%E7%B1%BB/" style="font-size: 13px;">聚类</a> <a href="/bigbig-shark/tags/%E8%87%AA%E5%8A%A8%E9%A9%BE%E9%A9%B6/" style="font-size: 13.33px;">自动驾驶</a> <a href="/bigbig-shark/tags/%E8%AE%A1%E7%AE%97%E6%9C%BA%E8%A7%86%E8%A7%893D/" style="font-size: 13px;">计算机视觉3D</a> <a href="/bigbig-shark/tags/%E8%BD%BB%E9%87%8F%E7%BA%A7/" style="font-size: 13px;">轻量级</a>
    </div>
  </div>

    
  </div>
</aside>

  
  
<main class="main" role="main">
  <div class="content">
  <article id="post-面试准备" class="article article-type-post" itemscope itemtype="http://schema.org/BlogPosting">
    
    <div class="article-header">
      
        
  
    <h1 class="article-title" itemprop="name">
      面试准备
    </h1>
  

      
      <div class="article-meta">
        <span class="article-date">
    <i class="icon icon-calendar-check"></i>
	<a href="/bigbig-shark/2022/10/03/%E9%9D%A2%E8%AF%95%E5%87%86%E5%A4%87/" class="article-date">
	  <time datetime="2022-10-03T02:57:32.000Z" itemprop="datePublished">2022-10-03</time>
	</a>
</span>
        
  <span class="article-category">
    <i class="icon icon-folder"></i>
    <a class="article-category-link" href="/bigbig-shark/categories/%E5%8D%8A%E6%97%A5%E9%97%B2/">半日闲</a>
  </span>

        

        

	<span class="article-read hidden-xs">
    	<i class="icon icon-eye-fill" aria-hidden="true"></i>
    	<span id="/bigbig-shark/2022/10/03/%E9%9D%A2%E8%AF%95%E5%87%86%E5%A4%87/" class="leancloud_visitors"  data-flag-title="面试准备">
			<span class="leancloud-visitors-count">0</span>
		</span>
    </span>

        <span class="post-comment"><i class="icon icon-comment"></i> <a href="/bigbig-shark/2022/10/03/%E9%9D%A2%E8%AF%95%E5%87%86%E5%A4%87/#comments" class="article-comment-link">Comments</a></span>
        
	
		<span class="post-wordcount hidden-xs" itemprop="wordCount">Word Count: 2.6k(words)</span>
	
	
		<span class="post-readcount hidden-xs" itemprop="timeRequired">Read Count: 9(minutes)</span>
	

      </div>
    </div>
    <div class="article-entry marked-body" itemprop="articleBody">
      
        <!-- toc -->
<ul>
<li><a href="#%E4%B8%80-%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0%E5%BF%85%E7%9F%A5%E7%AE%97%E6%B3%95">一、机器学习必知算法</a>
<ul>
<li><a href="#1-linear-regression-%E7%BA%BF%E6%80%A7%E5%9B%9E%E5%BD%92">1. Linear Regression 线性回归</a></li>
<li><a href="#2-logistic-regression-%E9%80%BB%E8%BE%91%E5%9B%9E%E5%BD%92">2. Logistic Regression 逻辑回归</a></li>
<li><a href="#3-decision-trees-%E5%86%B3%E7%AD%96%E6%A0%91">3. Decision Trees 决策树</a></li>
<li><a href="#4-random-forests-%E9%9A%8F%E6%9C%BA%E6%A3%AE%E6%9E%97">4. Random Forests 随机森林</a></li>
<li><a href="#5-svm%E6%94%AF%E6%8C%81%E5%90%91%E9%87%8F%E6%9C%BA">5. SVM支持向量机</a></li>
<li><a href="#6-knn-k-%E8%BF%91%E9%82%BB">6. KNN K-近邻</a></li>
<li><a href="#7-k-means-k%E5%9D%87%E5%80%BC">7. K-means K均值</a></li>
<li><a href="#8-naive-bayes-%E6%9C%B4%E7%B4%A0%E8%B4%9D%E5%8F%B6%E6%96%AF">8. Naive Bayes 朴素贝叶斯</a></li>
<li><a href="#9-%E9%99%8D%E7%BB%B4%E7%AE%97%E6%B3%95">9. 降维算法</a></li>
</ul>
</li>
<li><a href="#%E4%BA%8C-%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0%E5%9F%BA%E7%A1%80">二、深度学习基础</a>
<ul>
<li><a href="#cs231n%E7%AC%94%E8%AE%B0">CS231n笔记</a></li>
<li><a href="#%E5%90%84%E7%A7%8D%E6%8D%9F%E5%A4%B1%E5%87%BD%E6%95%B0httpscloudtencentcomdeveloperarticle1950150">各种损失函数</a>
<ul>
<li><a href="#mse-loss">MSE Loss</a></li>
<li><a href="#mae-loss">MAE Loss</a></li>
<li><a href="#mse%E5%92%8Cmae%E5%8C%BA%E5%88%AB">MSE和MAE区别</a></li>
<li><a href="#huber-loss">Huber Loss</a></li>
<li><a href="#cross-entropy-loss">Cross Entropy Loss</a></li>
</ul>
</li>
<li><a href="#%E6%95%B0%E6%8D%AE%E9%9B%86">数据集</a></li>
<li><a href="#%E6%A2%AF%E5%BA%A6%E4%B8%8B%E9%99%8D">梯度下降</a>
<ul>
<li><a href="#gradient">Gradient</a></li>
<li><a href="#batch-gradient-descent">Batch Gradient Descent</a></li>
<li><a href="#sgd">SGD</a></li>
<li><a href="#mini-batch-gd%E5%B0%8F%E6%89%B9%E9%87%8F%E6%A2%AF%E5%BA%A6%E4%B8%8B%E9%99%8D">Mini-batch GD小批量梯度下降</a></li>
<li><a href="#momentum">Momentum</a></li>
<li><a href="#nesterov">Nesterov</a></li>
<li><a href="#adagrad">Adagrad</a></li>
<li><a href="#rmsprop">RMSprop</a></li>
<li><a href="#adam">Adam</a></li>
</ul>
</li>
<li><a href="#%E5%A6%82%E4%BD%95%E5%85%8B%E6%9C%8D%E8%BF%87%E6%8B%9F%E5%90%88">如何克服过拟合</a>
<ul>
<li><a href="#bn">BN</a></li>
<li><a href="#dropout">Dropout</a></li>
<li><a href="#regularization">Regularization</a></li>
<li><a href="#cross-validation">cross-validation</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#%E4%B8%89-cnn%E7%BB%8F%E5%85%B8%E7%BD%91%E7%BB%9C%E7%BB%93%E6%9E%84">三、CNN经典网络结构</a></li>
<li><a href="#%E5%9B%9B-pytorch%E7%9A%84%E6%94%AF%E6%92%91%E5%92%8C%E5%90%84%E7%A7%8D%E5%8C%85">四、PyTorch的支撑和各种包</a>
<ul>
<li><a href="#0-pytorch%E7%9A%84%E6%94%AF%E6%92%91">0. PyTorch的支撑</a>
<ul>
<li><a href="#00-%E4%BB%80%E4%B9%88%E6%98%AF%E5%BC%A0%E9%87%8F">0.0 什么是张量</a></li>
<li><a href="#01-pytorch%E7%9A%84%E8%AE%A1%E7%AE%97%E5%9B%BE">0.1 PyTorch的计算图</a></li>
</ul>
</li>
<li><a href="#1-torch">1. torch</a></li>
<li><a href="#2-torchnn%E5%92%8Ctorchnnfunctional">2. torch.nn和torch.nn.functional</a></li>
<li><a href="#3-torchautograd">3. torch.autograd</a></li>
<li><a href="#4-torchoptim">4. torch.optim</a></li>
<li><a href="#5-torchutilsdata">5. torch.utils.data</a></li>
<li><a href="#6-torchvision">6. torchvision</a>
<ul>
<li><a href="#61-torchvisiondatasets">6.1 torchvision.datasets</a></li>
<li><a href="#62-torchvisionmodels">6.2 torchvision.models</a></li>
<li><a href="#63-torchvisiontransforms">6.3 torchvision.transforms</a></li>
<li><a href="#64-torchvisionutils">6.4 torchvision.utils</a></li>
</ul>
</li>
<li><a href="#7-from-pil-import-image">7. from PIL import Image</a></li>
<li><a href="#8-matplotlib">8. matplotlib</a></li>
</ul>
</li>
<li><a href="#%E4%BA%94-%E7%9B%AE%E6%A0%87%E6%A3%80%E6%B5%8B%E7%9B%B8%E5%85%B3">五、目标检测相关</a>
<ul>
<li><a href="#map">mAP</a></li>
</ul>
</li>
</ul>
<!-- tocstop -->
<p>匆匆忙忙做了个简单梳理，以后可以慢慢完善和深入。</p>
<h2><span id="一-机器学习必知算法">一、机器学习必知算法</span></h2>
<blockquote>
<p>机器学习三要素：策略、模型、算法</p>
<p>机器学习算法分类：监督学习、无监督学习、强化学习</p>
</blockquote>
<h3><span id="1-linear-regression-线性回归">1. Linear Regression 线性回归</span></h3>
<h3><span id="2-logistic-regression-逻辑回归">2. Logistic Regression 逻辑回归</span></h3>
<h3><span id="3-decision-trees-决策树">3. Decision Trees 决策树</span></h3>
<h3><span id="4-random-forests-随机森林">4. Random Forests 随机森林</span></h3>
<h3><span id="5-svm支持向量机">5. SVM支持向量机</span></h3>
<h3><span id="6-knn-k-近邻">6. KNN K-近邻</span></h3>
<h3><span id="7-k-means-k均值">7. K-means K均值</span></h3>
<p>无监督</p>
<h3><span id="8-naive-bayes-朴素贝叶斯">8. Naive Bayes 朴素贝叶斯</span></h3>
<h3><span id="9-降维算法">9. 降维算法</span></h3>
<p>Principal Component Analysis主成分分析PCA</p>
<p>Principal Component Analysis(PCA)是最常用的线性降维方法，它的目标是通过某种线性投影，将高维的数据映射到低维的空间中表示，并期望在所投影的维度上数据的方差最大，以此使用较少的数据维度，同时保留住较多的原数据点的特性。</p>
<p>通俗的理解，如果把所有的点都映射到一起，那么几乎所有的信息（如点和点之间的距离关系）都丢失了，而如果映射后方差尽可能的大，那么数据点则会分散开来，以此来保留更多的信息。可以证明，PCA是丢失原始数据信息最少的一种线性降维方式。（实际上就是最接近原始数据，但是PCA并不试图去探索数据内在结构）</p>
<h2><span id="二-深度学习基础">二、深度学习基础</span></h2>
<h3><span id="cs231n笔记">CS231n笔记</span></h3>
<p>L1（曼哈顿距离）、L2 Distance（欧式距离）、 Cross Validation（交叉验证）</p>
<h3><span id="各种损失函数"></span></h3>
<p>首先区分一下损失函数和代价函数：</p>
<ul>
<li>Loss Function损失函数：通常是针对单个训练样本而言，给定一个模型输出和一个真实数据，损失函数输出一个实值损失。</li>
<li>Cost Function代价函数：通常是针对整个训练集或者一个batch的总损失。</li>
</ul>
<h4><span id="mse-loss">MSE Loss</span></h4>
<p>均方差损失：Mean Squared Error Loss</p>
<h4><span id="mae-loss">MAE Loss</span></h4>
<p>平均绝对误差损失：Mean Absolute Error Loss，也称L1 Loss</p>
<h4><span id="mse和mae区别">MSE和MAE区别</span></h4>
<p>MAE 和 MSE 作为损失函数的主要区别是：MSE 损失相比 MAE 通常可以更快地收敛，但 MAE 损失对于 outlier 更加健壮，即更加不易受到 outlier 影响。<strong>MSE 通常比 MAE 可以更快地收敛</strong>。当使用梯度下降算法时，MSE 损失的梯度为 ，而 MAE 损失的梯度为 ，即 MSE 的梯度的 scale 会随误差大小变化，而 MAE 的梯度的 scale 则一直保持为 1，即便在绝对误差 很小的时候 MAE 的梯度 scale 也同样为 1，这实际上是非常不利于模型的训练的。当然你可以通过在训练过程中动态调整学习率缓解这个问题，但是总的来说，损失函数梯度之间的差异导致了 MSE 在大部分时候比 MAE 收敛地更快。这个也是 MSE 更为流行的原因。<strong>MAE 对于 outlier 更加 robust</strong>。</p>
<h4><span id="huber-loss">Huber Loss</span></h4>
<p>将MSE和MAE结合起来，在误差接近于0时使用MSE，在误差较大时使用MAE。（针对训练过程）</p>
<p>缺点是需要一个超参数。</p>
<h4><span id="cross-entropy-loss">Cross Entropy Loss</span></h4>
<p>交叉熵损失函数</p>
<p><img src="https://gitee.com/tina-yao/bigbig-shark/raw/master/imgs/iPadEntrance/2.png" alt="image-20221002184159856"></p>
<h3><span id="数据集">数据集</span></h3>
<p>CIFAR-10：10 classes， 60000 images in total，for each class there has 5000 images with labels and 1000 images without labels. Each image is of size 32 * 32.</p>
<h3><span id="梯度下降">梯度下降</span></h3>
<h4><span id="gradient">Gradient</span></h4>
<p>梯度的本质是一个向量，表示某一函数在该点处的方向导数沿着该方向取得最大值。</p>
<h4><span id="batch-gradient-descent">Batch Gradient Descent</span></h4>
<p>对所有样本</p>
<p>缺点：</p>
<ul>
<li>慢</li>
<li>无法处理超出内存容量的数据样本</li>
<li>不能在线更新模型，即在运行过程中，不能增加新的样本</li>
<li>对于凸误差函数，批梯度下降法能够保证收敛到全局最小值；但对于非凸函数，很有可能收敛到一个局部最小值。</li>
</ul>
<h4><span id="sgd">SGD</span></h4>
<p>Stochastic Gradient Descent随机梯度下降，对每个样本计算梯度，并更新一次参数。</p>
<ul>
<li>优点：
<ul>
<li>SGD运行速度快</li>
<li>可以用于在线学习</li>
</ul>
</li>
<li>缺点：
<ul>
<li>可以高方差频繁地更新，导致目标函数出现剧烈波动。</li>
<li>由于SGD的波动性，一方面，波动性使得SGD可以跳到新的和潜在更好的局部最优。另一方面，这使得最终收敛到特定最小值的过程变得复杂，因为SGD会一直持续波动。然而，已经证明当我们缓慢减小学习率，SGD和批梯度下降法具有相同的收敛行为，对于凸优化和非凸优化，可以分别收敛到局部最小值和全局最小值。</li>
</ul>
</li>
</ul>
<h4><span id="mini-batch-gd小批量梯度下降">Mini-batch GD小批量梯度下降</span></h4>
<ul>
<li>mini-batch梯度下降法最终结合了上述两种方法的优点，在每次更新时使用一个小批量训练样本。</li>
<li>减少参数更新的方差，这样可以获得更稳定的收敛结果。</li>
<li>可以利用最新的深度学习库中高度优化的矩阵优化方法，高效地求解每个小批量数据的梯度。</li>
</ul>
<h4><span id="momentum">Momentum</span></h4>
<ul>
<li>在每次下降时都加上之前运动方向的动量。</li>
<li>当遇到一个局部最优的时候，有可能在原有动量的基础上冲出这个局部最优点。</li>
<li>普通梯度下降法完全由梯度决定，这就可能导致在寻找最优解的过程中出现严重震荡而导致速度变慢；而在加上动量的基础上，优化方向由动量和梯度共同决定，可以使震荡减弱，更快地运动到最优解。</li>
<li>Momentum的具体实现：
<ul>
<li>在普通的梯度下降法中引入指数加权移动平均；</li>
<li>即定义一个动量，它是梯度的指数加权移动平均值，然后使用该值代替原来的梯度来更新。</li>
</ul>
</li>
</ul>
<p><img src="https://gitee.com/tina-yao/bigbig-shark/raw/master/imgs/iPadEntrance/1.png" alt></p>
<h4><span id="nesterov">Nesterov</span></h4>
<p>对Momentum方法的改进，先在前一个累计的梯度方向上进行跳跃，然后测量下一跳跃点的梯度并与之前点的动量进行加和，从而更新向量。</p>
<p>该方法对收敛速度没有提升。</p>
<h4><span id="adagrad">Adagrad</span></h4>
<p>采用了累积平方梯度，将学习率除以一个根号下的累积平方梯度加上一个极小量。</p>
<p><img src="https://gitee.com/tina-yao/bigbig-shark/raw/master/imgs/iPadEntrance/3.png" alt></p>
<p>缺点是：累计平方梯度，导致真正的学习率（梯度前起作用的黄色部分）过快接近于0，解决Adam。</p>
<h4><span id="rmsprop">RMSprop</span></h4>
<p>与AdaGrad类似，只是将平方梯度改成了指数移动平均。</p>
<p>能够解决AdaGrad梯度急剧减小的问题，在很多应用中都展示出优秀的学习率自适应能力。尤其在不稳定（Non-Stationary）的目标函数下，比基本的SGD、Momentum、AdaGrad表现更良好。</p>
<p><img src="https://gitee.com/tina-yao/bigbig-shark/raw/master/imgs/iPadEntrance/4.png" alt></p>
<h4><span id="adam">Adam</span></h4>
<p>结合了AdaGrad和RMSProp两种优化算法的优点。</p>
<p><img src="https://gitee.com/tina-yao/bigbig-shark/raw/master/imgs/iPadEntrance/5.png" alt></p>
<h3><span id="如何克服过拟合">如何克服过拟合</span></h3>
<h4><span id="bn">BN</span></h4>
<h4><span id="dropout">Dropout</span></h4>
<h4><span id="regularization">Regularization</span></h4>
<h4><span id="cross-validation">cross-validation</span></h4>
<p>当训练集和验证集都比较小时，可以使用交叉验证。在数据集上进行多次迭代</p>
<h2><span id="三-cnn经典网络结构">三、CNN经典网络结构</span></h2>
<ul>
<li>分类：
<ul>
<li>AlexNet</li>
<li>VGGNet</li>
<li>GoogLeNet</li>
<li>ResNet</li>
<li>DenseNet</li>
<li>HRNet</li>
</ul>
</li>
<li>目标检测
<ul>
<li>Anchor-based
<ul>
<li>two-stage
<ul>
<li>RCNN（Region-based，Selective Search）</li>
<li>SPP（Spatial Pyramid Pooling空间金字塔池化）</li>
<li>Fast-RCNN</li>
<li>Faster-RCNN</li>
</ul>
</li>
<li>one-stage
<ul>
<li>yolov1</li>
<li>SSD（引入了特征金字塔）</li>
<li>yolov2</li>
<li>retinanet</li>
<li>yolov3</li>
</ul>
</li>
</ul>
</li>
<li>Anchor-free
<ul>
<li>CornerNet</li>
<li>CenterNet</li>
</ul>
</li>
</ul>
</li>
</ul>
<h2><span id="四-pytorch的支撑和各种包">四、PyTorch的支撑和各种包</span></h2>
<h3><span id="0-pytorch的支撑">0. PyTorch的支撑</span></h3>
<h4><span id="00-什么是张量">0.0 什么是张量</span></h4>
<p>Tensor可以看作（包含单一类型的）多维矩阵，Scalar可以看成0维Tensor，Vector可以看成1维Tensor，Matrix可以看成2维Tensor；其实Tensor就是一种如同numpy之类的数据类型，而和numpy等普通数据类型不同的是，Tensor可以在在GPU上面进行运算、可以自动求梯度。</p>
<p>创建Tensor：torch.Tensor(x)</p>
<h4><span id="01-pytorch的计算图">0.1 PyTorch的计算图</span></h4>
<h3><span id="1-torch">1. torch</span></h3>
<p>张量的有关运算。如创建、索引、连接、转置、加减乘除、切片等。</p>
<h3><span id="2-torchnn和torchnnfunctional">2. torch.nn和torch.nn.functional</span></h3>
<p>里面有各种方法，包括卷积层、激活函数、池化层、批标准化BN、dropout、各种损失函数等。</p>
<h3><span id="3-torchautograd">3. torch.autograd</span></h3>
<p>提供Tensor所有操作的自动求导方法。</p>
<h3><span id="4-torchoptim">4. torch.optim</span></h3>
<p>各种参数优化方法，比如Adam、AdaGrad、RMSProp、SGD等</p>
<h3><span id="5-torchutilsdata">5. torch.utils.data</span></h3>
<p>用于加载数据</p>
<p>torch.utils.data.DataLoader</p>
<h3><span id="6-torchvision">6. torchvision</span></h3>
<p>视觉工具包，这个包可以独立于PyTorch。</p>
<h4><span id="61-torchvisiondatasets">6.1 torchvision.datasets</span></h4>
<p>提供几个常用数据集的加载，设计上都是继承torch.utils.data.Dataset，主要包括MNIST，CIFAR10/100、ImageNet、COCO等。</p>
<h4><span id="62-torchvisionmodels">6.2 torchvision.models</span></h4>
<p>提供深度学习中各种经典网络的网络结构以及预训练好的模型，包括AlexNet、VGG系列、ResNet系列、Inception系列等。</p>
<h4><span id="63-torchvisiontransforms">6.3 torchvision.transforms</span></h4>
<p>提供常用的数据预处理操作，主要包括对Tensor以及PIL Image对象的操作。</p>
<h4><span id="64-torchvisionutils">6.4 torchvision.utils</span></h4>
<p>将给定的Tensor保存成Image文件，还有很多可视化工具</p>
<h3><span id="7-from-pil-import-image">7. from PIL import Image</span></h3>
<p>我们一般在PyTorch中处理的图像无非以下几种格式：</p>
<ul>
<li>PIL：使用python自带图像处理库读出来的图片格式</li>
<li>numpy：使用opencv-python库读取出来的图片格式</li>
<li>tensor：pytorch中训练时所采取的向量格式（当然也可以说图片）</li>
</ul>
<p>from PIL import Image是在进行PIL与tensor的转换，也就是图片格式的转换。</p>
<h3><span id="8-matplotlib">8. matplotlib</span></h3>
<p>import matplotlib.pyplot as plt</p>
<h2><span id="五-目标检测相关">五、目标检测相关</span></h2>
<h3><span id="map">mAP</span></h3>
<p>全类平均准确率/全类平均精度</p>
<p><img src="https://gitee.com/tina-yao/bigbig-shark/raw/master/imgs/iPadEntrance/6.png" alt></p>
<p>（此处可以着重理解all detections和all ground truths，理解了这两个，就能轻松区分Precision和Recall）</p>

      
    </div>
    <div class="article-footer">
      <blockquote class="mt-2x">
  <ul class="post-copyright list-unstyled">
    
    <li class="post-copyright-link hidden-xs">
      <strong>本文链接：</strong>
      <a href="http://tina-yao.gitee.io/bigbig-shark/2022/10/03/%E9%9D%A2%E8%AF%95%E5%87%86%E5%A4%87/" title="面试准备" target="_blank" rel="external">http://tina-yao.gitee.io/bigbig-shark/2022/10/03/面试准备/</a>
    </li>
    
    <li class="post-copyright-license">
      <strong>版权声明： </strong> 本博客所有文章除特别声明外，均采用 <a href="http://creativecommons.org/licenses/by/4.0/deed.zh" target="_blank" rel="external">CC BY 4.0 CN协议</a> 许可协议。转载请注明出处！
    </li>
  </ul>
</blockquote>


<div class="panel panel-default panel-badger">
  <div class="panel-body">
    <figure class="media">
      <div class="media-left">
        <a href="https://tina-yao.gitee.io/bigbig-shark/" target="_blank" class="img-burn thumb-sm visible-lg">
          <img src="/bigbig-shark/images/avatar.jpg" class="img-rounded w-full" alt="">
        </a>
      </div>
      <div class="media-body">
        <h3 class="media-heading"><a href="https://tina-yao.gitee.io/bigbig-shark/" target="_blank"><span class="text-dark">大鲨鱼</span><small class="ml-1x">CV&amp;Robots</small></a></h3>
        <div>格物致知，诚意力行。</div>
      </div>
    </figure>
  </div>
</div>


    </div>
  </article>
  
    
  <section id="comments">
  	
      <div id="vcomments"></div>
    
  </section>


  
</div>

  <nav class="bar bar-footer clearfix" data-stick-bottom>
  <div class="bar-inner">
  
  <ul class="pager pull-left">
    
    <li class="prev">
      <a href="/bigbig-shark/2022/10/06/%E8%AF%9A%E9%82%80%E8%AF%B8%E5%90%9B%E5%85%B1%E8%B5%8F%E5%8F%A4%E4%BB%8A%E4%B8%AD%E5%A4%96%E8%AF%97%E8%AF%8D/" title="诚邀诸君共赏古今中外诗词"><i class="icon icon-angle-left" aria-hidden="true"></i><span>&nbsp;&nbsp;Newer</span></a>
    </li>
    
    
    <li class="next">
      <a href="/bigbig-shark/2022/09/30/PASCAL-VOC%E6%95%B0%E6%8D%AE%E9%9B%86%E5%8F%8A%E8%87%AA%E5%B7%B1%E5%88%B6%E4%BD%9C%E6%95%B0%E6%8D%AE%E9%9B%86/" title="PASCAL VOC数据集及自己制作数据集"><span>Older&nbsp;&nbsp;</span><i class="icon icon-angle-right" aria-hidden="true"></i></a>
    </li>
    
    
  </ul>
  
  
  <!-- Button trigger modal -->
  <button type="button" class="btn btn-fancy btn-donate pop-onhover bg-gradient-warning" data-toggle="modal" data-target="#donateModal"><span>$</span></button>
  <!-- <div class="wave-icon wave-icon-danger btn-donate" data-toggle="modal" data-target="#donateModal">
    <div class="wave-circle"><span class="icon"><i class="icon icon-bill"></i></span></div>
  </div> -->
  
  
  <div class="bar-right">
    
    <div class="share-component" data-sites="weibo,qq,wechat" data-mobile-sites="weibo,qq"></div>
    
  </div>
  </div>
</nav>
  
<!-- Modal -->
<div class="modal modal-center modal-small modal-xs-full fade" id="donateModal" tabindex="-1" role="dialog">
  <div class="modal-dialog" role="document">
    <div class="modal-content donate">
      <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
      <div class="modal-body">
        <div class="donate-box">
          <div class="donate-head">
            <p>Maybe you could buy me a cup of coffee.</p>
          </div>
          <div class="tab-content">
            <div role="tabpanel" class="tab-pane fade active in" id="alipay">
              <div class="donate-payimg">
                <img src="https://gitee.com/tina-yao/bigbig-shark/raw/master/images/donate/alipayimg.PNG#images/donate/alipayimg.png" alt="Scan Qrcode" title="Scan" />
              </div>
              <p class="text-muted mv">Scan this qrcode</p>
              <p class="text-grey">Open alipay app scan this qrcode, buy me a coffee!</p>
            </div>
            <div role="tabpanel" class="tab-pane fade" id="wechatpay">
              <div class="donate-payimg">
                <img src="https://gitee.com/tina-yao/bigbig-shark/raw/master/images/donate/wechatpayimg.PNG#images/donate/wechatpayimg.png" alt="Scan Qrcode" title="Scan" />
              </div>
              <p class="text-muted mv">Scan this qrcode</p>
              <p class="text-grey">Open wechat app scan this qrcode, buy me a coffee!</p>
            </div>
          </div>
          <div class="donate-footer">
            <ul class="nav nav-tabs nav-justified" role="tablist">
              <li role="presentation" class="active">
                <a href="#alipay" id="alipay-tab" role="tab" data-toggle="tab" aria-controls="alipay" aria-expanded="true"><i class="icon icon-alipay"></i> alipay</a>
              </li>
              <li role="presentation" class="">
                <a href="#wechatpay" role="tab" id="wechatpay-tab" data-toggle="tab" aria-controls="wechatpay" aria-expanded="false"><i class="icon icon-wepay"></i> wechat payment</a>
              </li>
            </ul>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>



</main>

  <footer class="footer" itemscope itemtype="http://schema.org/WPFooter">
	
	
    <ul class="social-links">
    	
        <li><a href="https://gitee.com/tina-yao" target="_blank" title="Gitee" data-toggle=tooltip data-placement=top><i class="icon icon-gitee"></i></a></li>
        
    </ul>

    <div class="copyright">
    	
        &copy; 2023 BigbigShark
        
        <div class="publishby">
        <!--
        	Theme by <a href="https://github.com/cofess" target="_blank"> cofess </a>base on <a href="https://github.com/cofess/hexo-theme-pure" target="_blank">pure</a>.
        -->
        </div>
    </div>
</footer>
  <script src="//cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
<script>
window.jQuery || document.write('<script src="js/jquery.min.js"><\/script>')
</script>

<script src="/bigbig-shark/js/plugin.min.js"></script>


<script src="/bigbig-shark/js/application.js"></script>


    <script>
(function (window) {
    var INSIGHT_CONFIG = {
        TRANSLATION: {
            POSTS: 'Posts',
            PAGES: 'Pages',
            CATEGORIES: 'Categories',
            TAGS: 'Tags',
            UNTITLED: '(Untitled)',
        },
        ROOT_URL: '/bigbig-shark/',
        CONTENT_URL: '/bigbig-shark/content.json',
    };
    window.INSIGHT_CONFIG = INSIGHT_CONFIG;
})(window);
</script>

<script src="/bigbig-shark/js/insight.js"></script>






   




   
    
  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/valine"></script>
  <script type="text/javascript">
  var GUEST = ['nick', 'mail', 'link'];
  var meta = 'nick,mail,link';
  meta = meta.split(',').filter(function(item) {
    return GUEST.indexOf(item) > -1;
  });
  new Valine({
    el: '#vcomments',
    verify: false,
    notify: false,
    appId: '8pTCCvyyLGXskH0XW0fWHg7l-gzGzoHsz',
    appKey: 'id3rlCPRdbEoSpUfhJgcLhDO',
    placeholder: 'Just go go',
    avatar: 'mm',
    meta: meta,
    pageSize: '10' || 10,
    visitor: true
  });
  </script>

     







<script src="/bigbig-shark/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginModelPath":"assets/","model":{"jsonPath":"/bigbig-shark/live2dw/assets/tororo.model.json"},"display":{"position":null,"width":300,"height":600},"log":false,"pluginJsPath":"lib/","pluginRootPath":"live2dw/","tagMode":false});</script></body>
</html>